#pragma once

#include <string>
#include <jsoncpp/json/json.h>

namespace WordMemory
{
    struct User
    {
        User(int id,
             const std::string &username,
             const std::string &password,
             const std::string &real_name,
             const std::string &created_at)
            : _id(id)
            , _username(username)
            , _password(password)
            , _real_name(real_name)
            , _created_at(created_at)
        {}

        int _id;
        std::string _username;
        std::string _password;
        std::string _real_name;
        std::string _created_at;

        Json::Value to_json() const
        {
            Json::Value json;
            json["id"] = _id;
            json["username"] = _username;
            json["password"] = _password;
            json["real_name"] = _real_name;
            json["created_at"] = _created_at;
            return json;
        }

        void from_json(const Json::Value &json)
        {
            _id = json["id"].asInt();
            _username = json["username"].asString();
            _password = json["password"].asString();
            _real_name = json["real_name"].asString();
            _created_at = json["created_at"].asString();
        }
    };
}